<script lang="ts" setup>
import { Button,Checkbox ,showToast} from 'vant';
import { reactive,onMounted,ref,onActivated } from 'vue';
import { useRouter } from 'vue-router'
import request from '@/utils/request';
import {useUserStore} from '@/stores/index';
const userStore = useUserStore()
const router = useRouter()
const agreement = ref(true)

const form = reactive({
  mobile:'',
  name:'',
  idcard:''
})
function submit(){
  if(!form.name){
    return showToast({
      message: '请输入姓名'  
    })
  }
  if(!form.mobile){
    return showToast({
      message: '请输入手机号'  
    })
  }
  if(!form.idcard){
    return showToast({
      message: '请输入身份证号'  
    })
  }
  request('/api/h5/userAuth','POST',form)
  .then(res => {
    router.push('/query/upload1')
    userStore.info = {
      ...form,
      order_no:res.order_no
    }
  })
  
  
}
  onActivated(() => {
    userStore.$reset()
    console.log('onActivated login')
  })
</script>
<template>
  <div class="container-box">
    <div class="logo-box">
      <img src="@/assets/query/logo.png" alt="">
      快信通
    </div>
    <div class="content">
      <div class="input-item">
        <div class="label">
          姓名
        </div>
        <input v-model="form.name" type="text">
      </div>
      <div class="input-item">
        <div class="label">
          手机号
        </div>
        <input v-model="form.mobile" type="text">
      </div>
      <div class="input-item">
        <div class="label">
          身份证
        </div>
        <input v-model="form.idcard" type="text">
      </div>
      <Button type="primary" @click="submit" :disabled="!agreement" style="margin-top: 36px;" block>下一步</Button>
    </div>
      <Checkbox  icon-size="16px" v-model="agreement" style="margin-top: 34px;" >
    <div class="argment">
        <div>您已阅读并同意<span class="link" @click.stop="router.push('/agreement')">《隐私协议》</span></div>
    </div>
      </Checkbox>
  </div>
</template>
<style lang="less" scoped>
.container-box {
  .logo-box {
    font-size: 31px;
    font-weight: bold;
    color: #fff;
    display: flex;
    align-items: center;
    img{
      width: 70px;
    height: 50px;
    }
  }

  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;


  .content {
    border-radius: 10px;
    width: var(--content-width);
    margin: 40px auto 0;
    background-color: #fff;
    padding: 50px 20px 25px;
    .input-item{
      display: flex;
      align-items: center;
      &:not(:first-child){
        margin-top: 24px;
      }
      .label{
        width: 4em;
        color:#1A1A1A;
        font-weight: 500;
        font-size: 14px;
      }
      input{
        border: none;
        flex-grow: 1;
        border: 1px solid #BFC4EB;
        height: 44px;
        border-radius: 5px;
        padding-left: 1em;
      }
    }
  }
  .argment{
    // display: flex;
    // align-items: center;
    color: #3D3D3D;
    font-size: 12px;
    .link{
      color: #4C77C4;
    }
  }
}
</style>